package com.hu.network.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;

/**
 * 作者：Administrator
 * 时间：2017/4/20
 * 描述：cn.efly.util
 */
public class JsonHelper {
    public static <T> String toJsonString(T tt) {
        try {
            return JSON.toJSONString(tt);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static <T> T parseObject(String json, TypeReference<T> typeReference) {
        try {
            return JSON.parseObject(json, typeReference.getType());
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
